/**
 * 
 */
package com.cea.papyrus.diagram.deployment.command;

import java.util.Iterator;

import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.uml2.uml.DeployedArtifact;
import org.eclipse.uml2.uml.Deployment;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Relationship;


/**
 * Delete factory specific to this diagram.
 * @author dumoulin
 *
 */
public class UMLDi2ElementDeleteFactory extends com.cea.papyrus.core.commands.factories.UMLDi2ElementDeleteFactory {

    /**
     * Singleton instance of the factory.
     */
    public static UMLDi2ElementDeleteFactory eINSTANCE = new UMLDi2ElementDeleteFactory();

    /**
     * Delete related relationships.
     * 
     * @param command the command
     * @param elt the elt
     */
    protected void deleteDeployedArtifactRelatedRelationships(Element elt, CompoundCommand command) {
        // Delete each UML element related (relationships for example)
        Iterator<Relationship> rIterator = elt.getRelationships().iterator();
        while(rIterator.hasNext()) {
            Relationship relationship = rIterator.next();
            if (!(relationship instanceof Deployment)){
                command.add(createCommand(relationship));
            }else {
                command.add(new DeconnectDeployedArtifactFromModelCommand((DeployedArtifact)elt,(Deployment)relationship));
            }
        }
    }

}
